home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / demos / graph < prev    next >
Encoding:
Text File  |  1995-07-01  |  3.4 KB  |  112 lines

  1. #!../blt_wish
  2.  
  3. if [file exists ../library] {
  4.     set blt_library ../library
  5. }
  6. option add *Blt_htext.Font *Times-Bold-R*14*
  7. option add *graph.xTitle "X Axis Label"
  8. option add *graph.yTitle "Y Axis Label"
  9. option add *graph.title "A Simple XY Graph"
  10. option add *graph.elemBackground red
  11.  
  12. set visual [winfo screenvisual .] 
  13. if { $visual != "staticgray" } {
  14.     option add *print.background yellow
  15.     option add *quit.background red
  16. }
  17.  
  18.  
  19. proc ConfigureGraph { interp graph } {
  20.     exec ../blt_wish -name GraphConfig -f ./grconf.tcl $interp $graph &
  21. }
  22.  
  23. set remote {}
  24. global graph
  25. set graph .graph
  26. blt_htext .header -text {%%
  27. %%This is an example of the blt_graph widget.  It displays two-variable 
  28. data with assorted line attributes and symbols.  The graph itself has 
  29. many components; x and y axis, legend, crosshairs, elements, etc.  
  30. You can configure any component by pressing this %% 
  31. button $blt_htext(widget).config -text button -bg green \
  32.     -command [list ConfigureGraph [winfo name .] $graph]
  33. $blt_htext(widget) append $blt_htext(widget).config
  34. %%.
  35.  
  36. To create a postscript file "xy.ps", press the %%
  37. button $blt_htext(widget).print -text print -command {
  38.   .graph postscript xy.ps -pagewidth 6.5i -pageheight 9i -landscape true
  39. $blt_htext(widget) append $blt_htext(widget).print
  40. %% button.}
  41.  
  42. blt_graph $graph
  43.  
  44. blt_htext .footer -text {Hit the %%
  45. button $blt_htext(widget).quit -text quit -command { 
  46.     catch "send GraphConfig after 1 exit" 
  47.     destroy .
  48. $blt_htext(widget) append $blt_htext(widget).quit 
  49. %% button when you've seen enough.%%
  50. label $blt_htext(widget).logo -bitmap BLT
  51. $blt_htext(widget) append $blt_htext(widget).logo -padx 20
  52. %%}
  53.  
  54. set X { 
  55.     2.00000e-01 4.00000e-01 6.00000e-01 8.00000e-01 1.00000e+00 
  56.     1.20000e+00 1.40000e+00 1.60000e+00 1.80000e+00 2.00000e+00 
  57.     2.20000e+00 2.40000e+00 2.60000e+00 2.80000e+00 3.00000e+00 
  58.     3.20000e+00 3.40000e+00 3.60000e+00 3.80000e+00 4.00000e+00 
  59.     4.20000e+00 4.40000e+00 4.60000e+00 4.80000e+00 5.00000e+00 
  60.  
  61. set Y1 { 
  62.     1.14471e+01 2.09373e+01 2.84608e+01 3.40080e+01 3.75691e+01 
  63.     3.91345e+01 3.92706e+01 3.93474e+01 3.94242e+01 3.95010e+01 
  64.     3.95778e+01 3.96545e+01 3.97313e+01 3.98081e+01 3.98849e+01 
  65.     3.99617e+01 4.00384e+01 4.01152e+01 4.01920e+01 4.02688e+01 
  66.     4.03455e+01 4.04223e+01 4.04990e+01 4.05758e+01 4.06526e+01 
  67. }
  68.  
  69. set Y2 { 
  70.     2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
  71.     1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
  72.     1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
  73.     1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
  74.     1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
  75. }
  76.  
  77. set Y3  { 
  78.     4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
  79.     2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
  80.     3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
  81.     4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
  82.     4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
  83. }
  84.  
  85. $graph element create line1 -xdata $X -ydata $Y2 \
  86.     -symbol cross -linewidth 1 
  87. $graph element create line2 -xdata $X -ydata $Y3 \
  88.     -symbol square -linewidth 1
  89. $graph element create line3 -xdata $X -ydata $Y1 \
  90.     -symbol plus -linewidth 1
  91.  
  92. #$graph crosshairs set on
  93.  
  94. pack append . \
  95.     .header { padx 20 pady 10 }  \
  96.     .graph {} \
  97.     .footer { padx 20 pady 10 }
  98.     
  99. wm min . 0 0
  100.  
  101. source features.tcl
  102. #SetCrosshairs $graph
  103. SetActiveLegend $graph
  104. SetClosestPoint $graph
  105. SetZoom $graph
  106.  
  107. wm min . 0 0
  108.  
  109.